#ifndef _VALUEFORM_H
#define _VALUEFORM_H

#include <QDialog>
#include <QList>
#include "ui_valueform.h"
#include "../define.h"

class QLineEdit;
class QLabel;
class QPushButton;
class QAbstractButton;

class ValueForm : public QDialog
{
	Q_OBJECT
public:
	/*
	enum ValueType {
		kValueTypeInteger = 0,
		kValueTypeDouble
	};
	*/

	ValueForm(double value,
			  const rng_tbl_s *range,
//			  ValueType type = kValueTypeDouble,
			  QWidget *parent = 0);
	~ValueForm();

	QString getValueString();

private slots:
	void EditingViaKeyboard();
	void EditingViaSpin();
	void DialogShouldReturn();

private:
//	void HandleValueType(ValueType type);
	void HandleIntegerValue();
	void HandleKeyboardInput(QLineEdit *line_edit,
							 const QPushButton *button);
	void InitValueString(double value);

	Ui_ValueForm ui_;
	QList<QAbstractButton *> number_buttons_;

	double max_value_;
	double min_value_;
	double value_step_;
	bool   is_signed_value_;
	bool   has_decimals_;
	/*
	QLabel       *pointLabel;
	QLabel       *unitLabel;
	QLineEdit    *intEdit;
	QLineEdit    *fraEdit;
	QPushButton  *intPlus;
	QPushButton  *intMinus;
	QPushButton  *fraPlus;
	QPushButton  *fraMinus;
	QPushButton  *deleteButton;
	QButtonGroup *numberButtons;
	QPushButton  *okButton;
	QPushButton  *cancelButton;
	*/
};

#endif // _VALUEFORM_H
